n, k, s = [int(t) for t in input().split()]

with_GPLT_score = dict()

for i in range(n):
    GPLT_score, PTA_score = [int(t) for t in input().split()]
    if GPLT_score < 175:
        continue
    if GPLT_score not in with_GPLT_score.keys():
        with_GPLT_score[GPLT_score] = list()
    with_GPLT_score[GPLT_score].append(PTA_score)


tot = 0

for i in range(k):
    for GPLT_score in with_GPLT_score.keys():
        if len(with_GPLT_score[GPLT_score]) < 1:
            continue
        cnt = 0

        if i == 0:  # 第 1 批
            qualified = [PTA_score for PTA_score in with_GPLT_score[GPLT_score] if PTA_score >= s]
            cnt += len(qualified)
            with_GPLT_score[GPLT_score] = [PTA_score for PTA_score in with_GPLT_score[GPLT_score] if PTA_score < s]

        if len(with_GPLT_score[GPLT_score]) > 0:
            cnt += 1
            with_GPLT_score[GPLT_score] = with_GPLT_score[GPLT_score][1:]

        tot += cnt

print(tot)
